<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>输入名字并排序</title>
</head>
<body>
<script>
    var input;
    var names = [];
    while ((input = prompt('Enter your name', '')) != '') {
        names.push(input);
    }

    names.sort();
    names.forEach(function (item) {
        document.write(item + '<br/>');
    })
</script>
</body>
</html>